package com.neuedu.corejava.ch8;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

public class TestCheckException {

	// check exception 和 runtime exception

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("输入A：");
		int a = scanner.nextInt();
		System.out.println("输入B：");
		int b = scanner.nextInt();

		// java.lang.ArithmeticException 可能发生RuntimeException
		/*
		 * if (b==0) { System.out.println("除数不能为0默认除1"); b=1; }
		 */
		try {
			int c = a / b;
		} catch (ArithmeticException e) {
			System.out.println("发生了算术运算异常");
			// 查看内存出错信息，打印堆栈信息
			e.printStackTrace();
		}

		System.out.println("main方法执行完毕");
	}
}
